home *** CD-ROM | disk | FTP | other *** search
- global gTable, debug
-
- on closeDB
- global gDB
- if objectp(gDB) then
- gDB = 0
- end if
- end
-
- on initDB fileName, tableName
- global gDB
- gDB = new(xtra("V12dbe"), basePath() & fileName, "ReadOnly", EMPTY)
- gTable = new(xtra("V12table"), mGetRef(gDB), tableName)
- end
-
- on countDB
- mGoFirst(gTable)
- numRecs = mSelectCount(gTable)
- mGoFirst(gTable)
- put "Found" && numRecs && "records in the glassware database"
- end
-
- on initRecipes
- global gRecipes, gOldRecipes, gIngredients, gSecretRecipeBook
- if gOldRecipes then
- if FileExists(gSecretRecipeBook) and not authoring() then
- gRecipes = value(retrieveFile(gSecretRecipeBook))
- else
- gRecipes = getOldRecipesDB()
- end if
- exit
- end if
- gRecipes = [:]
- if 0 then
- initDB("recipes.v12", "recipes")
- mOrderBy(gTable, "drinkName")
- mSelectAll(gTable)
- gRecipes = mGetSelection(gTable, "PropertyList")
- closeDB()
- else
- initDB("recipes.v12", "recipes")
- mOrderBy(gTable, "recID")
- mSelectAll(gTable)
- ingredients = mGetSelection(gTable, "PropertyList")
- closeDB()
- initDB("recipes.v12", "recipeName")
- mOrderBy(gTable, "drinkName")
- mSelectAll(gTable)
- gRecipes = mGetSelection(gTable, "PropertyList")
- closeDB()
- end if
- repeat with thisDrink in gRecipes
- thisDrink[#RECID] = integer(thisDrink[#RECID])
- thisDrink[#DIFFICULTY] = integer(thisDrink[#DIFFICULTY])
- ingList = []
- specialCase = []
- repeat with X = 1 to count(ingredients)
- nextIng = ingredients[X]
- if nextIng[#RECID] = thisDrink[#RECID] then
- INGID = integer(nextIng[#INGID])
- add(ingList, [#INGID: INGID, #ingName: findingredientbyid(INGID), #q: nextIng[#q], #p: nextIng[#p], #o: nextIng[#order]])
- repeat with Y = 1 to count(gIngredients)
- thisIng = gIngredients[Y]
- refname = getPropAt(gIngredients, Y)
- if thisIng[#INGID] = INGID then
- if thisIng[#Xbottle] then
- add(specialCase, 1)
- else
- if thisIng[#CATID] = 5 then
- add(specialCase, 2)
- else
- case refname of
- #lemontwist, #limetwist:
- add(specialCase, 3)
- #coatandrim:
- add(specialCase, 4)
- #Muddle:
- add(specialCase, 5)
- end case
- end if
- end if
- exit repeat
- end if
- end repeat
- end if
- end repeat
- if count(specialCase) then
- thisDrink[#SPECIAL_CASE] = duplicate(specialCase)
- end if
- thisDrink[#ingredients] = bubbleSort(duplicate(ingList))
- end repeat
- end
-
- on bubbleSort ingList
- repeat with X = count(ingList) down to 2
- repeat with Y = X - 1 down to 1
- if ingList[Y][#o] > ingList[X][#o] then
- temp1 = duplicate(ingList[X])
- temp2 = duplicate(ingList[Y])
- ingList[X] = temp2
- ingList[Y] = temp1
- end if
- end repeat
- end repeat
- return ingList
- end
-
- on initIngredients
- global gIngredients, gOldIngredients, gSecretIngredients
- gIngredients = [:]
- if gOldIngredients then
- if FileExists(gSecretIngredients) and not authoring() then
- gIngredients = value(retrieveFile(gSecretIngredients))
- else
- gIngredients = getOldIngredientsDB()
- end if
- sort(gIngredients)
- else
- gIngredients = [:]
- initDB("recipes.v12", "ingredients")
- mOrderBy(gTable, "ingID")
- mSelectAll(gTable)
- temp = mGetSelection(gTable, "PropertyList")
- repeat with X = 1 to count(temp)
- thisIng = symbol(temp[X][#refname])
- addProp(gIngredients, thisIng, temp[X])
- deleteProp(gIngredients[thisIng], #refname)
- oldLaser = getLaser(thisIng)
- if (oldLaser = "void") or (oldLaser = "<void>") or (oldLaser = EMPTY) then
- gIngredients[thisIng][#laserPoint] = VOID
- else
- if oldLaser starts "ppint" then
- nothing()
- else
- gIngredients[thisIng][#laserPoint] = value("point" & oldLaser)
- end if
- end if
- oldColor = getLiquidColor(thisIng)
- if (oldColor = "void") or (oldColor = "<void>") or (oldColor = EMPTY) then
- gIngredients[thisIng][#color] = VOID
- else
- gIngredients[thisIng][#color] = value("rgb" & oldColor)
- end if
- gIngredients[thisIng][#CATID] = integer(gIngredients[thisIng][#CATID])
- deleteProp(gIngredients[thisIng], #QUANTITY_FIELDNAME)
- deleteProp(gIngredients[thisIng], #POINTS_FIELDNAME)
- gIngredients[thisIng][#Xbottle] = integer(gIngredients[thisIng][#Xbottle])
- altList = []
- alt = value("list" & gIngredients[thisIng][#ALTERNATEING])
- if not voidp(alt) then
- repeat with z = 1 to count(alt) / 2
- first = (z * 2) - 1
- second = z * 2
- add(altList, [#ingA: alt[first], #pA: alt[second]])
- end repeat
- end if
- if count(altList) then
- gIngredients[thisIng][#alt] = altList
- end if
- deleteProp(gIngredients[thisIng], #ALTERNATEING)
- end repeat
- closeDB()
- end if
- end
-
- on correctUserTips
- global gUserTips
- repeat with X = 1 to count(gUserTips)
- gUserTips[X][#tipText] = replaceAltOption(gUserTips[X][#tipText])
- end repeat
- end
-
- on initUserTips
- global gUserTips, gOldUserTips
- if gOldUserTips then
- gUserTips = getOldUserTipsDB()
- else
- gUserTips = [:]
- initDB("recipes.v12", "Tip_Table")
- mOrderBy(gTable, "ID")
- mSelectAll(gTable)
- temp = mGetSelection(gTable, "PropertyList")
- repeat with X = 1 to count(temp)
- thisTip = temp[X]
- tipName = thisTip[#TIP_NAME]
- tipSymbol = symbol(tipName)
- addProp(gUserTips, tipSymbol, [#tipCode: tipSymbol, #tipName: tipName, #tipText: thisTip[#tip], #tipType: symbol(thisTip[#TIP_CAT])])
- end repeat
- closeDB()
- end if
- end
-
- on cleanUpRecipes
- global gRecipes, gOldRecipes
- oldPrecision = the floatPrecision
- set the floatPrecision to 2
- if not gOldRecipes then
- if not voidp(gRecipes) then
- member("recipeDB").scriptText = "on getOldRecipesDB" & RETURN & "return" && gRecipes & RETURN & "end"
- end if
- gOldRecipes = 1
- end if
- set the floatPrecision to oldPrecision
- end
-
- on cleanupIngredients
- global gIngredients, gOldIngredients
- if not gOldIngredients then
- oldPrec = the floatPrecision
- set the floatPrecision to 3
- if not voidp(gIngredients) then
- member("ingredientDB").scriptText = "on getOldIngredientsDB" & RETURN & "return" && gIngredients & RETURN & "end"
- end if
- gOldIngredients = 1
- set the floatPrecision to oldPrec
- end if
- end
-
- on cleanupUserTips
- global gUserTips, gOldUserTips
- if not gOldUserTips then
- if not voidp(gUserTips) then
- member("userTipsDB").scriptText = "on getOldUserTipsDB" & RETURN & "return" && gUserTips & RETURN & "end"
- end if
- gOldUserTips = 1
- end if
- end
-
- on cleanupCharActions
- global gCharacterActions, gOldCharActions
- if not gOldCharActions then
- if not voidp(gCharacterActions) then
- member("charactionsDB").scriptText = "on getOldCharActionsDB" & RETURN & "return" && gCharacterActions & RETURN & "end"
- end if
- gOldCharActions = 1
- end if
- end
-
- on cleanupGlassware
- global gGlassware, gOldGlassware
- if not gOldGlassware then
- if not voidp(gGlassware) then
- member("glasswareDB").scriptText = "on getOldGlasswareDB" & RETURN & "return" && gGlassware & RETURN & "end"
- end if
- gOldGlassware = 1
- end if
- end
-
- on cleanupGameLevels
- global gGameSetup, gOldGameLevels
- if not gOldGameLevels then
- if not voidp(gGameSetup) then
- member("gameLevelsDB").scriptText = "on getOldGameLevelsDB" & RETURN & "return" && gGameSetup & RETURN & "end"
- end if
- gOldGameLevels = 1
- end if
- end
-
- on cleanupFlashRects
- global gFlashRects, gOldFlashRects
- if not gOldFlashRects then
- set the floatPrecision to 0
- if not voidp(gFlashRects) then
- member("flashRectsDB").scriptText = "on getOldFlashRectsDB" & RETURN & "return" && gFlashRects & RETURN & "end"
- end if
- gOldFlashRects = 1
- set the floatPrecision to 2
- end if
- end
-
- on cleanupcharInfo
- global gOldCharInfo, gImplementedCharacters
- if not gOldCharInfo then
- if not voidp(gImplementedCharacters) then
- member("charInfoDB").scriptText = "on getOldCharInfoDB" & RETURN & "return" && gImplementedCharacters & RETURN & "end"
- end if
- gOldCharInfo = 1
- end if
- end
-
- on cleanup
- cleanUpRecipes()
- cleanupIngredients()
- cleanupCharActions()
- cleanupGlassware()
- cleanupFlashRects()
- cleanupcharInfo()
- closeDB()
- end
-